VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsEinStein"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Declare Function CreatePen Lib "gdi32.dll" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As Long
Private Declare Function PolyPolyline Lib "gdi32.dll" (ByVal hdc As Long, ByRef lppt As POINTAPI, ByRef lpdwPolyPoints As Long, ByVal cCount As Long) As Long
Private Declare Function SelectObject Lib "gdi32.dll" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32.dll" (ByVal hObject As Long) As Long
Private Declare Function FillRect Lib "user32.dll" (ByVal hdc As Long, ByRef lpRect As RECT, ByVal hBrush As Long) As Long
Private Declare Function GetSysColor Lib "user32.dll" (ByVal nIndex As Long) As Long

Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)

Implements IGameState

Private Type typeEinSteinState
 nPlayerJustMoved As Byte
 nResult As Byte 'always precomputed, 0=not finished, 1=draw, 2=win w.r.t playerJustMoved, 3=lose, i.e. the real one Xor 3
 nMoveCount As Byte '0,1 or 2
 nBlockCount As Byte 'bit 0-3: player1, bit 4-7: player2, only used when nMoveCount=2
 b(24) As Byte 'bit 0-3: block index (1-6), bit 4: player index
 nRandomFactor As Byte 'only used when nMoveCount=2
End Type

Private m_t As typeEinSteinState
Private m_nMoves As Long

Private Sub IGameState_ClearUserMoves()
m_nMoves = -1
End Sub

Friend Sub CloneFrom(ByRef t As typeEinSteinState)
m_t = t
End Sub

Private Function IGameState_Clone() As IGameState
Dim obj As New clsEinStein
obj.CloneFrom m_t
Set IGameState_Clone = obj
End Function

Private Function IGameState_DoMove(ByVal lpData As Long, ByVal nSize As Long) As Boolean
Dim i As Long, j As Long, k As Long, n As Long
Dim bData(1) As Byte
Dim b(5) As Byte
'///
If lpData = 0 Or nSize < 2 Then Exit Function
CopyMemory bData(0), ByVal lpData, 2
'///
m_t.nPlayerJustMoved = (m_t.nPlayerJustMoved And 1&) + 1
IGameState_DoMove = True
'///
If m_t.nMoveCount < 2 Then
 '///arrange blocks
 Debug.Assert (bData(0) And &HF0&) = &HF0&
 n = (bData(0) And &HF&) Or (bData(1) * &H10&)
 For i = 2 To 6
  k = n
  n = n \ i
  k = k - n * i
  b(6 - i) = k
  For j = 7 - i To 5
   If b(j) >= k Then b(j) = b(j) + 1
  Next j
 Next i
 For i = 0 To 5
  j = b(i)
  Select Case j
  Case 0, 1, 2
   k = 0
  Case 3, 4
   j = j - 3
   k = 1
  Case Else
   Debug.Assert j = 5
   j = 0
   k = 2
  End Select
  If m_t.nMoveCount = 1 Then
   j = 4 - j
   k = 4 - k
  End If
  m_t.b(k * 5 + j) = (m_t.nMoveCount * &H10&) Or (i + 1)
 Next i
 '///
 m_t.nMoveCount = m_t.nMoveCount + 1
 m_t.nBlockCount = &H66&
Else
 '///move block and update game result
 Debug.Assert bData(0) >= 0 And bData(0) < 25 And bData(1) >= 0 And bData(1) < 25
 i = m_t.b(bData(0)) 'src
 j = m_t.b(bData(1)) 'dest
 Debug.Assert i > 0 And ((i Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) <> 0
 m_t.b(bData(0)) = 0
 m_t.b(bData(1)) = i
 '///check if all blocks are eaten. warning: no sanity check
 If j > 0 Then
  If j And &H10& Then
   m_t.nBlockCount = m_t.nBlockCount - &H10&
   If m_t.nBlockCount < &H10& Then m_t.nResult = 2
  Else
   m_t.nBlockCount = m_t.nBlockCount - 1&
   If (m_t.nBlockCount And &HF&) = 0 Then m_t.nResult = 2
  End If
 End If
 '///check if it goes to the goal. warning: no sanity check
 If bData(1) = 0 Or bData(1) = 24 Then m_t.nResult = 2
End If
'///
If m_t.nMoveCount = 2 Then
 '///update random factor
 m_t.nRandomFactor = 1 + Int(6 * Rnd)
End If
End Function

Private Function IGameState_Draw(ByVal bm As cDIBSection, ByVal nWidth As Long, ByVal nHeight As Long) As Boolean
Dim w As Long, h As Long
Dim r As RECT
Dim hpn As Long
Dim i As Long, j As Long
Dim p(23) As POINTAPI, m2(11) As Long
'///
w = nWidth \ 5
i = nHeight \ 6
If w > i Then w = i
'///background
h = CreateSolidBrush(GetSysColor(vbButtonFace And &HFF&))
r.Right = nWidth
r.Bottom = nHeight
FillRect bm.hdc, r, h
DeleteObject h
h = CreateSolidBrush(&HC0C0FF)
r.Top = w
r.Right = w
r.Bottom = w * 4
FillRect bm.hdc, r, h
r.Right = w * 2
r.Bottom = w * 3
FillRect bm.hdc, r, h
r.Right = w * 3
r.Bottom = w * 2
FillRect bm.hdc, r, h
DeleteObject h
h = CreateSolidBrush(&HFFC0C0)
r.Right = w * 5
r.Bottom = w * 6
r.Left = w * 2
r.Top = w * 5
FillRect bm.hdc, r, h
r.Left = w * 3
r.Top = w * 4
FillRect bm.hdc, r, h
r.Left = w * 4
r.Top = w * 3
FillRect bm.hdc, r, h
DeleteObject h
'///grid
For i = 0 To 5
 p(i * 4).x = w * i
 p(i * 4).y = w
 p(i * 4 + 1).x = p(i * 4).x
 p(i * 4 + 1).y = w * 6
 p(i * 4 + 2).y = p(i * 4).x + w
 p(i * 4 + 3).x = w * 5
 p(i * 4 + 3).y = p(i * 4 + 2).y
Next i
For i = 0 To 11
 m2(i) = 2
Next i
hpn = SelectObject(bm.hdc, CreatePen(0, 2, vbBlack))
PolyPolyline bm.hdc, p(0), m2(0), 12
'///boxes
h = 0
For j = 0 To 4
 For i = 0 To 4
  r.Left = m_t.b(h)
  If r.Left > 0 Then
   If r.Left And &H10& Then r.Top = vbBlue Else r.Top = vbRed
   Form1.m_fnt.DrawTextXP bm.hdc, CStr(r.Left And &HF&), w * i, w * (j + 1), w, w, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOCLIP, r.Top, , True
  End If
  h = h + 1
 Next i
Next j
'///button and available moves
If m_t.nMoveCount < 2 Then
 Form1.m_fnt.DrawTextXP bm.hdc, "Reset", 0, 0, w * 2, w, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOCLIP, vbBlack, , True
 If m_nMoves >= &H1000000 Then
  h = m_nMoves \ &H1000000
  j = m_nMoves
  If m_t.nMoveCount = 1 Then r.Top = vbBlue Else r.Top = vbRed
  For i = 1 To h
   r.Right = j And &HF&
   j = j \ &H10&
   r.Bottom = r.Right \ 4&
   r.Right = r.Right And 3&
   If m_t.nMoveCount = 1 Then
    r.Right = 4 - r.Right
    r.Bottom = 4 - r.Bottom
   End If
   Form1.m_fnt.DrawTextXP bm.hdc, CStr(i), w * r.Right, w * (r.Bottom + 1), w, w, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOCLIP, r.Top, , True
  Next i
  If h >= 6 Then
   Form1.m_fnt.DrawTextXP bm.hdc, "OK", w * 3, 0, w * 2, w, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOCLIP, vbBlack, , True
  End If
 End If
Else
 Form1.m_fnt.DrawTextXP bm.hdc, CStr(m_t.nRandomFactor), 0, 0, w, w, DT_CENTER Or DT_VCENTER Or DT_SINGLELINE Or DT_NOCLIP, vbBlack, , True
 '///draw arrows
 m2(1) = 3
 m2(3) = 3
 m2(5) = 3
 For i = 0 To 5
  p(i).x = -1
 Next i
 For j = 0 To 4
  For i = 0 To 4
   h = m_t.b(j * 5 + i)
   If h > 0 And ((h Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) = 0 Then
    h = (h And &HF&) - 1
    Debug.Assert h >= 0 And h <= 5
    If m_t.nPlayerJustMoved And 1& Then
     p(h).x = 4 - i
     p(h).y = 4 - j
    Else
     p(h).x = i
     p(h).y = j
    End If
   End If
  Next i
 Next j
 j = 0
 For i = m_t.nRandomFactor - 1& To 0 Step -1
  If j Then p(i).x = -1
  If p(i).x >= 0 Then j = 1
 Next i
 j = 0
 For i = m_t.nRandomFactor - 1& To 5
  If j Then p(i).x = -1
  If p(i).x >= 0 Then j = 1
 Next i
 For h = 0 To 5
  If p(h).x >= 0 Then
   r.Left = 0
   If p(h).x < 4 Then
    'right
    p(r.Left + 6).x = w * (p(h).x + 1) - w \ 4
    p(r.Left + 6).y = w * (p(h).y + 1) + w \ 2
    p(r.Left + 7).x = w * (p(h).x + 1) + w \ 4
    p(r.Left + 7).y = p(r.Left + 6).y
    p(r.Left + 8).x = w * (p(h).x + 1)
    p(r.Left + 8).y = w * (p(h).y + 1) + w \ 4
    p(r.Left + 9).x = p(r.Left + 7).x
    p(r.Left + 9).y = p(r.Left + 7).y
    p(r.Left + 10).x = p(r.Left + 8).x
    p(r.Left + 10).y = w * (p(h).y + 2) - w \ 4
    r.Left = r.Left + 5
    If p(h).y < 4 Then
     'diagonal
     p(r.Left + 6).x = w * (p(h).x + 1) - w \ 4
     p(r.Left + 6).y = w * (p(h).y + 2) - w \ 4
     p(r.Left + 7).x = w * (p(h).x + 1) + w \ 4
     p(r.Left + 7).y = w * (p(h).y + 2) + w \ 4
     p(r.Left + 8).x = p(r.Left + 7).x
     p(r.Left + 8).y = w * (p(h).y + 2)
     p(r.Left + 9).x = p(r.Left + 7).x
     p(r.Left + 9).y = p(r.Left + 7).y
     p(r.Left + 10).x = w * (p(h).x + 1)
     p(r.Left + 10).y = p(r.Left + 7).y
     r.Left = r.Left + 5
    End If
   End If
   If p(h).y < 4 Then
    'down
    p(r.Left + 6).x = w * p(h).x + w \ 2
    p(r.Left + 6).y = w * (p(h).y + 2) - w \ 4
    p(r.Left + 7).x = p(r.Left + 6).x
    p(r.Left + 7).y = w * (p(h).y + 2) + w \ 4
    p(r.Left + 8).x = w * p(h).x + w \ 4
    p(r.Left + 8).y = w * (p(h).y + 2)
    p(r.Left + 9).x = p(r.Left + 7).x
    p(r.Left + 9).y = p(r.Left + 7).y
    p(r.Left + 10).x = w * (p(h).x + 1) - w \ 4
    p(r.Left + 10).y = p(r.Left + 8).y
    r.Left = r.Left + 5
   End If
   '///
   If r.Left > 0 Then
    If m_t.nPlayerJustMoved And 1& Then
     For i = 6 To r.Left + 5
      p(i).x = w * 5 - p(i).x
      p(i).y = w * 7 - p(i).y
     Next i
    End If
    PolyPolyline bm.hdc, p(6), m2(0), (r.Left \ 5) * 2
   End If
  End If
 Next h
End If
'///
DeleteObject SelectObject(bm.hdc, hpn)
End Function

Private Function IGameState_FilterByRandomFactor(ByVal lpData As Long, ByVal nSize As Long) As Boolean
Dim i As Long, j As Long, m As Long
Dim bData(1) As Byte
Dim b(5) As Byte
'///
If m_t.nMoveCount < 2 Then
 IGameState_FilterByRandomFactor = True
 Exit Function
End If
'///
If lpData = 0 Or nSize < 2 Then Exit Function
CopyMemory bData(0), ByVal lpData, 2
'///
For j = 0 To 4
 For i = 0 To 4
  m = m_t.b(j * 5 + i)
  If m > 0 And ((m Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) = 0 Then
   m = (m And &HF&) - 1
   Debug.Assert m >= 0 And m <= 5
   b(m) = 1
  End If
 Next i
Next j
j = 0
For i = m_t.nRandomFactor - 1& To 0 Step -1
 If j Then b(i) = 0
 If b(i) Then j = 1
Next i
j = 0
For i = m_t.nRandomFactor - 1& To 5
 If j Then b(i) = 0
 If b(i) Then j = 1
Next i
'///
Debug.Assert bData(0) >= 0 And bData(0) < 25
i = m_t.b(bData(0))
Debug.Assert i > 0 And ((i Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) = 0
i = (i And &HF&) - 1
Debug.Assert i >= 0 And i <= 5
IGameState_FilterByRandomFactor = b(i)
End Function

Private Function IGameState_GetMoves(bData() As Byte, nSize As Long, ByVal bRespectRandomFactor As Boolean) As Long
Dim i As Long, j As Long, k As Long, l As Long, m As Long, n As Long
Dim p(5) As POINTAPI
'///
nSize = 2
'///
If m_t.nMoveCount < 2 Then
 ReDim bData(19)
 For i = 0 To 9
  j = Int(720 * Rnd)
  bData(i * 2) = &HF0& Or (j And &HF&)
  bData(i * 2 + 1) = j \ &H10&
 Next i
 IGameState_GetMoves = 10
Else
 For i = 0 To 5
  p(i).x = -1
 Next i
 For j = 0 To 4
  For i = 0 To 4
   m = m_t.b(j * 5 + i)
   If m > 0 And ((m Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) = 0 Then
    m = (m And &HF&) - 1
    Debug.Assert m >= 0 And m <= 5
    If m_t.nPlayerJustMoved And 1& Then
     p(m).x = 4 - i
     p(m).y = 4 - j
    Else
     p(m).x = i
     p(m).y = j
    End If
   End If
  Next i
 Next j
 If bRespectRandomFactor Then
  j = 0
  For i = m_t.nRandomFactor - 1& To 0 Step -1
   If j Then p(i).x = -1
   If p(i).x >= 0 Then j = 1
  Next i
  j = 0
  For i = m_t.nRandomFactor - 1& To 5
   If j Then p(i).x = -1
   If p(i).x >= 0 Then j = 1
  Next i
 End If
 '///
 For m = 0 To 5
  If p(m).x >= 0 Then
   If p(m).x < 4 Then
    n = n + 1
    If p(m).y < 4 Then n = n + 2
   ElseIf p(m).y < 4 Then
    n = n + 1
   End If
  End If
 Next m
 If n = 0 Then Exit Function
 IGameState_GetMoves = n
 ReDim bData(n * 2 - 1)
 '///
 n = 0
 For m = 0 To 5
  If p(m).x >= 0 Then
   i = p(m).y * 5 + p(m).x
   j = i + 1
   k = i + 6
   l = i + 5
   If m_t.nPlayerJustMoved And 1& Then
    i = 24 - i
    j = 24 - j
    k = 24 - k
    l = 24 - l
   End If
   If p(m).x < 4 Then
    'right
    bData(n) = i
    bData(n + 1) = j
    n = n + 2
    If p(m).y < 4 Then
     'diagonal
     bData(n) = i
     bData(n + 1) = k
     n = n + 2
    End If
   End If
   If p(m).y < 4 Then
    'down
    bData(n) = i
    bData(n + 1) = l
    n = n + 2
   End If
  End If
 Next m
 Debug.Assert IGameState_GetMoves * 2 = n
End If
End Function

Private Function IGameState_GetRandomMoves(bData() As Byte, nSize As Long, ByVal bReversed As Boolean) As Boolean
Dim i As Long, j As Long, k As Long, m As Long, n As Long
Dim b(35) As Byte
'///
nSize = 2
ReDim bData(1)
'///
If m_t.nMoveCount < 2 Then
 j = Int(720 * Rnd)
 bData(0) = &HF0& Or (j And &HF&)
 bData(1) = j \ &H10&
 IGameState_GetRandomMoves = True
Else
 For j = 0 To 4
  For i = 0 To 4
   k = j * 5 + i
   If m_t.nPlayerJustMoved And 1& Then k = 24 - k
   m = m_t.b(k)
   If m > 0 And ((m Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) = 0 Then
    If i < 4 Then
     'right
     b(n * 2) = k
     If m_t.nPlayerJustMoved And 1& Then b(n * 2 + 1) = k - 1 _
     Else b(n * 2 + 1) = k + 1
     n = n + 1
     If j < 4 Then
      'diagonal
      b(n * 2) = k
      If m_t.nPlayerJustMoved And 1& Then b(n * 2 + 1) = k - 6 _
      Else b(n * 2 + 1) = k + 6
      n = n + 1
     End If
    End If
    If j < 4 Then
     'down
     b(n * 2) = k
     If m_t.nPlayerJustMoved And 1& Then b(n * 2 + 1) = k - 5 _
     Else b(n * 2 + 1) = k + 5
     n = n + 1
    End If
   End If
  Next i
 Next j
 If n = 0 Then Exit Function
 n = Int(n * Rnd)
 bData(0) = b(n * 2)
 bData(1) = b(n * 2 + 1)
 IGameState_GetRandomMoves = True
End If
End Function

Private Function IGameState_GetResult(ByVal nPlayerJustMoved As Long) As Long
Dim i As Long
i = m_t.nResult
IGameState_GetResult = i Xor 3 Xor (i >= 2 And (nPlayerJustMoved Xor m_t.nPlayerJustMoved) And 1&)
End Function

Private Function IGameState_GetUserMoves(bData() As Byte, nSize As Long) As Boolean
Dim i As Long, j As Long, k As Long, n As Long
Dim b(5) As Byte
'///
ReDim bData(1)
nSize = 2
'///
If m_t.nMoveCount < 2 Then
 If m_nMoves >= &H6000000 Then
  'get index
  For i = 0 To 5
   j = m_nMoves And &HF&
   m_nMoves = m_nMoves \ &H10&
   Select Case j
   Case 0, 1, 2
    b(i) = j
   Case 4, 5
    b(i) = j - 1
   Case 8
    b(i) = 5
   Case Else
    Debug.Assert False
    Exit Function
   End Select
  Next i
  'conver index to number
  For i = 0 To 4
   k = b(i)
   n = n * (6 - i) + k
   For j = i + 1 To 5
    If b(j) > k Then b(j) = b(j) - 1
   Next j
  Next i
  'over
  bData(0) = &HF0& Or (n And &HF&)
  bData(1) = n \ &H10&
  IGameState_GetUserMoves = True
 End If
Else
 If m_nMoves >= 0 Then
  bData(0) = m_nMoves And &HFF&
  bData(1) = (m_nMoves And &HFF00&) \ &H100&
  Debug.Assert bData(0) >= 0 And bData(0) < 25 And bData(1) >= 0 And bData(1) < 25
  IGameState_GetUserMoves = True
 End If
End If
End Function

Private Function IGameState_OnMouseDown(ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal Button As MouseButtonConstants, ByVal Shift As ShiftConstants) As Long
Dim i As Long, j As Long, m As Long
Dim p(5) As POINTAPI
'///
nWidth = nWidth \ 5
nHeight = nHeight \ 6
If nWidth > nHeight Then nWidth = nHeight
nHeight = nWidth \ 4
'///
If x < 0 Or y < 0 Then Exit Function
'///
If m_t.nMoveCount < 2 Then
 '///arrange blocks
 x = x \ nWidth
 y = y \ nWidth
 If x >= 5 Or y >= 6 Then Exit Function
 If (x <= 1 And y = 0) Or Button = vbRightButton Then
  m_nMoves = -1
  IGameState_OnMouseDown = 1
  Exit Function
 End If
 If y = 0 Then
  If x >= 3 And m_nMoves >= &H6000000 Then
   IGameState_OnMouseDown = 2
   Exit Function
  End If
 Else
  y = y - 1
  If m_t.nMoveCount = 1 Then
   x = 4 - x
   y = 4 - y
  End If
  If x + y <= 2 Then
   x = y * 4& + x
   m = m_nMoves \ &H1000000
   i = m_nMoves
   Do While m > 0 And x <> (i And &HF&)
    i = i \ &H10&
    m = m - 1
   Loop
   If m = 0 Then
    If m_nMoves < 0 Then m_nMoves = 0
    m_nMoves = (m_nMoves Or (x * CLng(16 ^ (m_nMoves \ &H1000000)))) + &H1000000
    IGameState_OnMouseDown = 1
    Exit Function
   End If
  End If
 End If
Else
 '///move block
 If m_t.nPlayerJustMoved And 1& Then
  x = nWidth * 5 - x
  y = nWidth * 7 - y
 End If
 For i = 0 To 5
  p(i).x = -1
 Next i
 For j = 0 To 4
  For i = 0 To 4
   m = m_t.b(j * 5 + i)
   If m > 0 And ((m Xor (m_t.nPlayerJustMoved * &H10&)) And &H10&) = 0 Then
    m = (m And &HF&) - 1
    Debug.Assert m >= 0 And m <= 5
    If m_t.nPlayerJustMoved And 1& Then
     p(m).x = 4 - i
     p(m).y = 4 - j
    Else
     p(m).x = i
     p(m).y = j
    End If
   End If
  Next i
 Next j
 j = 0
 For i = m_t.nRandomFactor - 1& To 0 Step -1
  If j Then p(i).x = -1
  If p(i).x >= 0 Then j = 1
 Next i
 j = 0
 For i = m_t.nRandomFactor - 1& To 5
  If j Then p(i).x = -1
  If p(i).x >= 0 Then j = 1
 Next i
 For m = 0 To 5
  If p(m).x >= 0 Then
   If p(m).x < 4 Then
    'right
    i = nWidth * (p(m).x + 1) - x
    j = nWidth * (p(m).y + 1) + nWidth \ 2 - y
    If i > -nHeight And j > -nHeight And i < nHeight And j < nHeight Then
     m_nMoves = (p(m).y * 5 + p(m).x) * &H101& + &H100&
     If m_t.nPlayerJustMoved And 1& Then m_nMoves = &H1818& - m_nMoves
     IGameState_OnMouseDown = 2
     Exit Function
    End If
    If p(m).y < 4 Then
     'diagonal
     i = nWidth * (p(m).x + 1) - x
     j = nWidth * (p(m).y + 2) - y
     If i > -nHeight And j > -nHeight And i < nHeight And j < nHeight Then
      m_nMoves = (p(m).y * 5 + p(m).x) * &H101& + &H600&
      If m_t.nPlayerJustMoved And 1& Then m_nMoves = &H1818& - m_nMoves
      IGameState_OnMouseDown = 2
      Exit Function
     End If
    End If
   End If
   If p(m).y < 4 Then
    'down
    i = nWidth * p(m).x + nWidth \ 2 - x
    j = nWidth * (p(m).y + 2) - y
    If i > -nHeight And j > -nHeight And i < nHeight And j < nHeight Then
     m_nMoves = (p(m).y * 5 + p(m).x) * &H101& + &H500&
     If m_t.nPlayerJustMoved And 1& Then m_nMoves = &H1818& - m_nMoves
     IGameState_OnMouseDown = 2
     Exit Function
    End If
   End If
  End If
 Next m
End If
'///
Beep
End Function

Private Function IGameState_OnMouseMove(ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal Button As MouseButtonConstants, ByVal Shift As ShiftConstants) As Long
'do nothing
End Function

Private Function IGameState_OnMouseUp(ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal Button As MouseButtonConstants, ByVal Shift As ShiftConstants) As Long
'do nothing
End Function

Private Property Get IGameState_PlayerJustMoved() As Long
IGameState_PlayerJustMoved = m_t.nPlayerJustMoved
End Property
